import { IFeidaoAiBrowserComponent } from '@feidao/web/interfaces';
//import set from '@feidao/web/atom/browser/local/set';
import { send_msg as url } from './config';
import nodejs from '@feidao/web/atom/browser/msg/nodejs';
import render from '@feidao/web/atom/browser/render/render';
import fire from '@feidao/web/atom/browser/msg/fire';
import P02 from './P02';
import P03 from './P03';

export default async function (fd: IFeidaoAiBrowserComponent, ...args: any[]) {
	const data = args[0].data;
	if (data) {
		const course_no = data.course_no;
		const teaching_class_id = data.teaching_class_id;
		const version_number = data.version_number;
		const teaching_class = data.teaching_class;
		// set(fd, 'course_no', course_no);
		// set(fd, 'teaching_class_id', teaching_class_id);
		// set(fd, 'version_number', version_number);
		const res2 = await nodejs<{ dataArray: Array<{}> }>(url, 'top_menu/course_query', { filter: { course_no } }, false, false);
		render(fd, res2.dataArray[0], P02, 'P02', 'inner');

		const res = [{ teaching_class_id: teaching_class_id, course_no: course_no, version_number: version_number, teaching_class: teaching_class }];

		render(fd, res[0], P03, 'P03', 'inner');
		const zj = fd.data.node.getAttribute('data-feidao-id');
		fire(zj, 'ec-001', { course_no, teaching_class_id, version_number, teaching_class });
	}

}

